<template>
  <div>
    <button v-on:click="addToCart">Add to cart</button>
    <p>Cart({{ cart }})</p>
    <div id="subcontainer" class="subcontainer"></div>
  </div>
</template>

<script>
import {registerMicroApps, start} from './test-micro-web/index'

const subList = [
  {
    name: 'vue2',
    activeRule: '/vue2',
    container: '#subcontainer',
    entry: 'http://127.0.0.1:5500/static/index.html'
  },
  // {
  //   name: 'vue2',
  //   activeRule: '/vue2',
  //   container: '#subcontainer',
  //   entry: 'http://localhost:9004/'
  // }
]

export default {
  name: 'App',
  components: {
  },
  data() {
    return {
      cart: 0
    }
  },
  methods: {
    addToCart() {
      this.cart += 1
    },
    register() {
      registerMicroApps(subList, {
        beforeLoad: [()=> {
          console.log('main beforeLoad')
        }],
        mounted: [()=> {
          console.log('main mounted')
        }],
        destoryed: [()=> {
          console.log('main destoryed')
        }],
      })
      start()
    }
  },
  mounted() {
    this.register()
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
